<?php
	/**
	*
	*@author 罟宁
	*data 2015年4月1日 上午11:48:10
	*
	*/
	include '../common/mysql_connect.php';
	header("content-Type:text/html;charset=utf-8");
	//连接数据库
	 
	if (Linking()){
	 //非空情况下进行数据插入
	    if (!empty($_POST)){
	        $lost_found=$_POST['lost_found'];
	        $position=$_POST['position'];
	        $title=$_POST['title'];
	        $datetime=strtotime($_POST['datetime']);
	        $place=$_POST['place'];
	        $class=$_POST['class'];
	        $detail=$_POST['detail'];
	        $contacter=$_POST['contacter'];
	        $tel=$_POST['tel'];
	        $qq=$_POST['qq'];
	        $Dtime=time();
	        
	        //判断tel和qq是否为数字
	        if (!is_numeric($qq)) {
	        	echo "<script>alert('请正确填写您的qq号码(数字)');location.href='./input.php'</script>";
	        }
	        if (!is_numeric($tel) || strlen($tel)!=11) {
	        	echo "<script>alert('请正确填写您的手机号码(11位纯数字)');location.href='./input.php'</script>";
	        }
	        $sql="insert into `".$dbname."`.`lost&found` (`lost&found`,`title`,`date`,`place`,`class`,`detail`,`contacter`,`tel`,`qq`,`position`,`Dtime`)values(\"".$lost_found."\",\"".$title."\",".$datetime.",\"".$place."\",\"".$class."\",\"".$detail."\",\"".$contacter."\",\"".$tel."\",".$qq.",\"".$position."\",".$Dtime.")";
	        
	        $result=mysql_query($sql);
	        
	        if (!$result){
	        	echo "<script>alert('数据写入失败，请联系我们');</script>";
	            @mysql_close($link);   
	        }else 
	            echo "<script>alert('提交成功');location.href='./output.php'</script>";
	            @mysql_close($link);
	    }else {
	        //mysql_close($link);
	        echo "<script>alert('有未填写的数据');location.href='./input.php'</script>";
	    }
	}else{
	    echo "连接出错";
	}
?>
